home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / DEMON / LANGUAGE / POT.ARC / !pOtLand / Core / main_tpl
Text File  |  1995-05-06  |  2KB  |  90 lines

  1. #include <pOtRTL.h>
  2. #include "<ModName>.h"
  3. #include <stddef.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <signal.h>
  7.  
  8. #ifdef __sun__
  9. #define atexit(x) on_exit(x,NULL)
  10. # ifndef L_tmpnam
  11. # define L_tmpnam 1024
  12. # endif
  13. #endif
  14.  
  15. #ifdef __MSDOS__
  16. # ifdef __TURBOC__
  17. extern unsigned _stklen = 32768;
  18. # endif
  19. #endif
  20.  
  21. #ifdef __riscos
  22. #  define unlink remove
  23. #endif
  24.  
  25. pOt_LONGINT pOt__gc_heapthreshold = 65536;
  26.  
  27. void catch(signo)
  28.     int signo;
  29. {
  30.   switch(signo) {
  31.     case SIGINT: pOt__halt(__FILE__,__LINE__,22); break;
  32.     case SIGFPE: pOt__halt(__FILE__,__LINE__,14); break;
  33.     default: pOt__halt(__FILE__,__LINE__,16); break;
  34.   }
  35.   
  36. static void rmparfile()
  37. {
  38.   unlink(pOt__parfilename);
  39.   free(pOt__parfilename);
  40. }
  41.   
  42. int main(argc, argv)
  43.     int argc;
  44.     char **argv;
  45. {
  46.   FILE *parfp, *nestedfp;
  47.   int ch;
  48.  
  49.   parfp = NULL;
  50.   nestedfp = NULL;
  51.  
  52.   signal(SIGINT, catch);
  53.   signal(SIGFPE, catch);
  54.  
  55.   if((pOt__parfilename = malloc(L_tmpnam))==NULL) {
  56.     fprintf(stderr, "%s\n", "Not enough memory to start the program.");
  57.     exit(255);
  58.   }
  59.   tmpnam(pOt__parfilename);
  60.   parfp = fopen(pOt__parfilename, "w");
  61.   if(parfp == NULL) {
  62.     fprintf(stderr, "%s %s.\n", "Cannot create ", pOt__parfilename);
  63.     exit(255);
  64.   }
  65.   while(*(++argv)) {
  66. #ifdef __riscos
  67.     if((*argv)[0] == '!') { /* clashes with @ in pathnames */
  68. #else
  69.     if((*argv)[0] == '@') {
  70. #endif
  71.       nestedfp = fopen((*argv + 1), "r");
  72.       if(nestedfp == NULL) fprintf(stderr, "%s not found.\n", (*argv + 1));
  73.       else {
  74.         while((ch = fgetc(nestedfp)) != EOF) fputc(ch, parfp);
  75.         fputc('\n', parfp);
  76.         fclose(nestedfp);
  77.       }
  78.     } else fprintf(parfp, "%s\n", *argv);
  79.   }
  80.   fclose(parfp);
  81.   atexit(rmparfile);
  82.   
  83.   pOt_<ModName>__body();
  84.   pOt_<Command>_<ModName>();
  85.  
  86.   exit(0);
  87.   return 0;
  88. }
  89.